﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Authority_Edit.aspx.cs"
    MasterPageFile="~/Admin/Admin.Master" Inherits="TimKen.Web.Admin.Authority.Authority_Edit" %>

<asp:Content ContentPlaceHolderID="ContentTitle" ID="title" runat="server">
    <%=GetLangString("PowerSet")%>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentLinkAction" runat="server">
    <span class="action-span"><a href="DataAdmin_List.aspx">
        <%=GetLangString("MenuDataAdministratorList")%></a></span>
</asp:Content>
<asp:Content ContentPlaceHolderID="ContentMain" ID="content" runat="server">
    <div class="list-div">
        <asp:GridView ID="grdActionList" runat="server" AutoGenerateColumns="False" Width="100%"
            ShowHeader="false" CssClass="grid">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <input type="checkbox" id="cbAction" onclick='check(<%#Eval("ActionID")%>,this)'
                            class="checkbox" name="actionCode[]" value='<%#Eval("ActionID")%>' /><%#LanguageID == 1 ? DataBinder.Eval(Container.DataItem, "ActionCodeCn").ToString() : DataBinder.Eval(Container.DataItem, "ActionCodeEn").ToString()%>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:DataList ID="dlChildActionList" runat="server" RepeatLayout="Flow" RepeatDirection="Vertical"
                            RepeatColumns="4" HeaderStyle-Width="20px" DataSource='<%# GetChildAction(int.Parse(DataBinder.Eval(Container.DataItem, "ActionID").ToString())) %>'
                            Width="100%" ItemStyle-HorizontalAlign="Left">
                            <ItemTemplate>
                                <input type="checkbox" id='cbActionParent<%#Eval("ParentID")%>' class="checkbox"
                                    name="actionCode[]" value='<%#Eval("ActionID")%>' /><%#LanguageID == 1 ? DataBinder.Eval(Container.DataItem, "ActionCodeCn").ToString() : DataBinder.Eval(Container.DataItem, "ActionCodeEn").ToString()%>
                            </ItemTemplate>
                        </asp:DataList>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <HeaderStyle HorizontalAlign="Center" />
        </asp:GridView>
    </div>
    <div class="list-div" style="margin-bottom: 5px">
        <table width="100%">
            <tr>
                <td>
                    <input type="checkbox" name="checkall" value="checkbox" onclick="checkAll(this.form, this);"
                        class="checkbox" /><%=GetLangString("SelectAll")%>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:Button ID="btnUpdate" runat="server" OnClick="btnUpdate_Click" CssClass="button" />
                </td>
            </tr>
        </table>
    </div>

    <script language="javascript">

    window.onload = function() {
        var actionList = "<%=ActionCodeStr%>";
        if (actionList != "") {

            var actionArray = actionList.split(',');

            for (var i = 0; i < document.getElementsByName("actionCode[]").length; i++) {
                for (var j = 0; j < actionArray.length; j++) {
                    if (document.getElementsByName("actionCode[]").item(i).value == actionArray[j]) {
                        document.getElementsByName("actionCode[]").item(i).checked = true;
                        break;
                    }
                }
            }
        }
    }
  
  
  
function checkAll(frm, checkbox)
{
  for (i = 0; i < frm.elements.length; i++)
  {
    if (frm.elements[i].name == 'actionCode[]')
    {
      frm.elements[i].checked = checkbox.checked;
    }
  }
}

function check(parentId,obj)
{
  var frm = obj.form;

    for (i = 0; i < frm.elements.length; i++) {
      if (frm.elements[i].name == "actionCode[]" && frm.elements[i].id == "cbActionParent"+parentId)
      {
           frm.elements[i].checked = obj.checked;
      }
    }
}
    </script>

</asp:Content>
